package com.loukou.lkt.lkt.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.loukou.lkt.lkt.entity.Supplier;

public interface SupplierDao extends PagingAndSortingRepository<Supplier, Integer>, JpaSpecificationExecutor<Supplier> {

	List<Supplier> findBySupplierCodeLikeAndSupplierNameLike(String supplierCode, String supplierName);
	
//	List<Supplier> findBySupplierCodeAndSupplierNameLike(String supplierCode, String supplierName);

	List<Supplier> findByIsUseAndIsExamineAndSupplierCode(int isUse, int isExamine, String supplierCode);
	
	Supplier findById(int id);
	
	@Query(value = "select * from lkt_supplier where supplier_name like '%?1%' and is_use = ?2 and is_examine=?3", nativeQuery = true)
	List<Supplier> findByIsUseAndIsExamineAndSupplierNameLike(String supplierName, int isUse, int isExamine);

	List<Supplier> findByIsUseAndIsExamineAndIdIn(int isUse, int isExamine, List<Integer> ids);
	
	List<Supplier> findBySupplierCodeLike(String supplierCode);
	
	List<Supplier> findBySupplierNameLike(String supplierName);

	List<Supplier> findByIdIn(List<Integer> ids);
	
	Supplier findBySupplierCode(String supplierCode);
}
